﻿<ViewDataFormTemplateSpec 
	xmlns="bb_appfx_viewdataformtemplate" 
	xmlns:common="bb_appfx_commontypes" 
	ID="d5fae807-b3bb-40b6-8c9f-6ebd54abd68a" 
	Name="RelationshipGetIdCustom"
	Description="Gets RelationshipId using ConstitId, ReciprocalId and RelationshipType"
	Author="Blackbaud Professional Services"
	DataFormInstanceID="f9500981-2973-41d6-b396-8cb3f0dcf339" 
	RecordType="Relationship"
	common:SecurityUIFolder="Service Bus Adapter"
	>

    <!-- define the SP that returns the data used by the form -->
    <SPDataForm SPName="USR_USP_DATAFORMTEMPLATE_VIEW_RELATIONSHIP_GET_GUID">
      <common:CreateProcedureSQL>
        <![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_VIEW_RELATIONSHIP_GET_GUID
(
	@ID uniqueidentifier, 
  @DATALOADED bit = 0 output,
	@RELATIONSHIPID uniqueidentifier = null output,
@RECIPROCALID uniqueidentifier,
  @RELATIONSHIPTYPEID uniqueidentifier

)
as

--(ID = RelationshipConstitID)

	set nocount on;
	
	-- be sure to set this, in case the select returns no rows
	set @DATALOADED = 0;
	
	-- populate the output parameters, which correspond to fields on the form.  Note that
	-- we set @DATALOADED = 1 to indicate that the load was successful.  Otherwise, the system
	-- will display a "no data loaded" message.
	select 
    @DATALOADED = 1,
		@RELATIONSHIPID = ID
	from 
    dbo.RELATIONSHIP 
	where 
    RELATIONSHIPCONSTITUENTID = @ID 
    AND RECIPROCALCONSTITUENTID = @RECIPROCALID
    AND RELATIONSHIPTYPECODEID = @RELATIONSHIPTYPEID
	
	return 0;
			]]>
      </common:CreateProcedureSQL>
    </SPDataForm>

    <!-- describe fields on the form, which correspond to parameters on the SP.  Note that system paramters 
	like the context @ID, @DATALOADED, and @CURRENTAPPUSERID need not be listed. -->
    <common:FormMetaData FixedDialog="true">
      <common:FormFields>
        <common:FormField FieldID="RELATIONSHIPID" Caption="Relationship ID" DataType="Guid" />
        <common:FormField FieldID="RECIPROCALID" Caption="Reciprocal ID" DataType="Guid" />
        <common:FormField FieldID="RELATIONSHIPTYPEID" Caption="Relationship Type ID" DataType="Guid" />        
      </common:FormFields>
    </common:FormMetaData>

  </ViewDataFormTemplateSpec>